package recursivecode;

import java.util.ArrayList;
import java.util.List;

/**
 * 功能描述:子序列字符串: 不连续的字符串
 * 2024/07/12
 *
 * @author ZhangYi
 */
public class SubsequenceString {

	public static void main(String[] args) {
		String str = "abcabcaaa";
		List<String> ans = getAllSubsequenceString(str);
		System.out.println(ans);
	}

	private static List<String> getAllSubsequenceString(String str) {
		if (str == null || str.length() == 0){
			return new ArrayList<>();
		}
		char[] chars = str.toCharArray();
		List<String> result = new ArrayList<>();
		parseAllSubsequenceString(chars,0,"",result);
		return result;
	}

	private static void parseAllSubsequenceString(char[] chars, int index, String path, List<String> result) {
		if (index == chars.length){
			result.add(path);
			return;
		}

		String no = path;
		parseAllSubsequenceString(chars, index+1, no, result);
		String yes = path + chars[index];
		parseAllSubsequenceString(chars, index+1, yes, result);
	}


}
